import Ajv from "ajv"
const ajv = new Ajv() // options can be passed, e.g. {allErrors: true}


const schema ={
    "type": "object",
    "properties": {
        "translated_text": {
            "type": "string"
        }
    }
}


const validate = ajv.compile(schema)

const inputData = {
    translated_text: "abc"
}


// Validate input data against the schema
const isValid = validate(inputData);

if (isValid) {
    console.log("Input data is valid");
} else {
    console.error("Input data is invalid");
    console.error(validate.errors);
}